#pragma once
#include<iostream>
#include<unistd.h>
#include<string>
class Channel
{
    public:
    Channel(int wfd,pid_t who):_wfd(wfd),_who(who)
    {
        _name="Channel-" + std::to_string(wfd) + "-" + std::to_string(who);
    }
    void Close()
    {
        close(_wfd);
    }
    std::string Name()
    {
        return _name;
    }
    void Send(int cmd)//自己指定的指令的编号
    {
        ::write(_wfd,&cmd,sizeof(cmd));
    }
    pid_t Id()
    {
        return _who;
    }
    int wFd()
    {
        return _wfd;
    }
    private:
    int _wfd;
    std::string _name;
    pid_t _who;
};